import 'package:flutter/material.dart';
import 'package:qgchat/common/global/global.dart';

class Emoji {
  // emoji组件
  static Widget widget(
    BuildContext context,
    Function callback, {
    bool show = true,
  }) {
    if (show) {
      return Container(
        width: w100(context),
        padding: EdgeInsets.symmetric(horizontal: px(30), vertical: px(20)),
        child: Wrap(
          children: emojis.map((item) {
            return _emojiBuild('$item', callback);
          }).toList(),
        ),
      );
    } else {
      return Container();
    }
  }

  // 生成单个emoji
  static Widget _emojiBuild(text, callback) {
    return Container(
      width: px(98),
      height: px(98),
      child: FlatButton(
        onPressed: () {
          callback(text);
        },
        padding: EdgeInsets.zero,
        child: Text('$text', style: TextStyle(fontSize: px(70))),
      ),
    );
  }

  // emoji数组
  static List<String> emojis = [
    "😀",
    "😂",
    "😃",
    "😅",
    "😆",
    "😉",
    "😊",
    "😋",
    "😎",
    "😍",
    "😘",
    "😚",
    "🙂",
    "🤔",
    "🤨",
    "😐",
    "🙄",
    "😏",
    "😣",
    "😥",
    "😮",
  ];
}
